home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
-
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: May, 1997
- // Author: Carol Levy
- //
- // Description:
- // dynExecuteEmitterCommands executes the emitter command, particle
- // command (to create the emission object) and connectDynamic command.
- //
- // Input Arguments():
- // int $isCreate -- create or add mode
- // string $emitterCmd -- the emitter command string
- //
- // Return Value:
- // None.
- //
-
- //
- // ============== dynExecuteEmitterCommands ==============
- //
- // SYNOPSIS
- // Execute the emitter command and connectDynamic command.
- // If executing a "Create"/positional emitter command, create
- // one emitter, create a particle and connect it to the emitter.
- // If executing an "Add" emitter command, add the emitter to
- // all items in the selection list, create a particle and connect
- // it to the emitters.
- //
- global proc dynExecuteEmitterCommands(int $isCreate, string $emitterCmd)
- {
- string $selected[] = `ls -sl`;
-
- if (!$isCreate && size($selected) == 0)
- {
- warning "Nothing is selected to add an emitter to.";
- return;
- }
-
- string $emitterNames[] = evalEcho($emitterCmd);
- string $shapeToConnect;
-
- // Create the particle to be emitted into.
- //
- string $cmd = "particle";
- string $particleNames[] = evalEcho($cmd);
- $shapeToConnect = $particleNames[0];
-
- // If die on exit was set, set this attribute of the particle shape.
- //
- if (`optionVar -query emitterDieOnExit`)
- {
- setAttr ($particleNames[0]+".dieOnEmissionVolumeExit") 1;
- }
-
- // If "need parent uv" was set, and this is a surface emitter,
- // add the parentU/parentV attributes to the particel shape.
- //
- if ((`optionVar -query emitterNeedParentUV`) &&
- (`optionVar -query emitterTypesOM` == 3))
- {
- // $particleNames[1] holds the shape name
- //
- addAttr -ln parentU -dt doubleArray $particleNames[1];
- addAttr -ln parentU0 -dt doubleArray $particleNames[1];
- addAttr -ln parentV -dt doubleArray $particleNames[1];
- addAttr -ln parentV0 -dt doubleArray $particleNames[1];
- }
-
- // If creating a positional emitter, connect it to the particle
- // just created.
- //
- if ($isCreate)
- {
- evalEcho connectDynamic -em $emitterNames[0] $shapeToConnect;
- }
- else
- {
- // If adding emitters to geometry, connect them all to the
- // particle just created. Emitter command returns name of
- // owner and actual emitter. We want to use the emitter's name
- // in the connect command, so as to connect only that emitter
- // and not any others it may own.
- //
- string $connectCmd = "connectDynamic ";
- for ($i = 0; $i < size($emitterNames)/2; $i++)
- {
- $connectCmd = $connectCmd + "-em "+$emitterNames[$i*2+1]+" ";
- }
-
- $connectCmd = $connectCmd + $shapeToConnect + "; ";
-
- evalEcho ($connectCmd);
- }
-
- // Make the new emitters selected.
- // The result of the "create emitter" command is
- // emitter1
- // The result of the add emitter command is
- // object1 emitter1 object2 emitter2 ... object_n emitter_n
- //
- select -cl;
-
- if ($isCreate)
- {
- for ($i = 0; $i < (size($emitterNames)); $i ++)
- {
- select -add $emitterNames[$i];
- }
- }
- else
- {
- for ($i = 1; $i < (size($emitterNames)); $i += 2)
- {
- select -add $emitterNames[$i];
- }
- }
- }
-
-